<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 12">
<meta name=Originator content="Microsoft Word 12">
<link rel=File-List href="text_files/filelist.xml">
<title>C++Script Manual</title>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>calum</o:Author>
  <o:LastAuthor>calum</o:LastAuthor>
  <o:Revision>16</o:Revision>
  <o:TotalTime>10</o:TotalTime>
  <o:Created>2008-12-18T21:45:00Z</o:Created>
  <o:LastSaved>2008-12-18T21:55:00Z</o:LastSaved>
  <o:Pages>4</o:Pages>
  <o:Words>1468</o:Words>
  <o:Characters>8372</o:Characters>
  <o:Lines>69</o:Lines>
  <o:Paragraphs>19</o:Paragraphs>
  <o:CharactersWithSpaces>9821</o:CharactersWithSpaces>
  <o:Version>12.00</o:Version>
 </o:DocumentProperties>
</xml><![endif]-->
<link rel=themeData href="text_files/themedata.thmx">
<link rel=colorSchemeMapping href="text_files/colorschememapping.xml">
<!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:TrackMoves>false</w:TrackMoves>
  <w:TrackFormatting/>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:DoNotPromoteQF/>
  <w:LidThemeOther>EN-GB</w:LidThemeOther>
  <w:LidThemeAsian>X-NONE</w:LidThemeAsian>
  <w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
  <w:Compatibility>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
   <w:DontGrowAutofit/>
   <w:SplitPgBreakAndParaMark/>
   <w:DontVertAlignCellWithSp/>
   <w:DontBreakConstrainedForcedTables/>
   <w:DontVertAlignInTxbx/>
   <w:Word11KerningPairs/>
   <w:CachedColBalance/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
  <m:mathPr>
   <m:mathFont m:val="Cambria Math"/>
   <m:brkBin m:val="before"/>
   <m:brkBinSub m:val="&#45;-"/>
   <m:smallFrac m:val="off"/>
   <m:dispDef/>
   <m:lMargin m:val="0"/>
   <m:rMargin m:val="0"/>
   <m:defJc m:val="centerGroup"/>
   <m:wrapIndent m:val="1440"/>
   <m:intLim m:val="subSup"/>
   <m:naryLim m:val="undOvr"/>
  </m:mathPr></w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" DefUnhideWhenUsed="true"
  DefSemiHidden="true" DefQFormat="false" DefPriority="99"
  LatentStyleCount="267">
  <w:LsdException Locked="false" Priority="0" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Normal"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="heading 1"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="heading 2"/>
  <w:LsdException Locked="false" Priority="9" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="heading 3"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 4"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 5"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 6"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 7"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 8"/>
  <w:LsdException Locked="false" Priority="9" QFormat="true" Name="heading 9"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 1"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 2"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 3"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 4"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 5"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 6"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 7"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 8"/>
  <w:LsdException Locked="false" Priority="39" Name="toc 9"/>
  <w:LsdException Locked="false" Priority="35" QFormat="true" Name="caption"/>
  <w:LsdException Locked="false" Priority="10" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Title"/>
  <w:LsdException Locked="false" Priority="1" Name="Default Paragraph Font"/>
  <w:LsdException Locked="false" Priority="11" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtitle"/>
  <w:LsdException Locked="false" Priority="22" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Strong"/>
  <w:LsdException Locked="false" Priority="20" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Emphasis"/>
  <w:LsdException Locked="false" Priority="59" SemiHidden="false"
   UnhideWhenUsed="false" Name="Table Grid"/>
  <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Placeholder Text"/>
  <w:LsdException Locked="false" Priority="1" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="No Spacing"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 1"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 1"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 1"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 1"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 1"/>
  <w:LsdException Locked="false" UnhideWhenUsed="false" Name="Revision"/>
  <w:LsdException Locked="false" Priority="34" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="List Paragraph"/>
  <w:LsdException Locked="false" Priority="29" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Quote"/>
  <w:LsdException Locked="false" Priority="30" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Quote"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 1"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 1"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 1"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 1"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 1"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 1"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 1"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 2"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 2"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 2"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 2"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 2"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 2"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 2"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 2"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 2"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 2"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 2"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 2"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 3"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 3"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 3"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 3"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 3"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 3"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 3"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 3"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 3"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 3"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 3"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 3"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 4"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 4"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 4"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 4"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 4"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 4"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 4"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 4"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 4"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 4"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 4"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 4"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 5"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 5"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 5"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 5"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 5"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 5"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 5"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 5"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 5"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 5"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 5"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 5"/>
  <w:LsdException Locked="false" Priority="60" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Shading Accent 6"/>
  <w:LsdException Locked="false" Priority="61" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light List Accent 6"/>
  <w:LsdException Locked="false" Priority="62" SemiHidden="false"
   UnhideWhenUsed="false" Name="Light Grid Accent 6"/>
  <w:LsdException Locked="false" Priority="63" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 1 Accent 6"/>
  <w:LsdException Locked="false" Priority="64" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Shading 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="65" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 1 Accent 6"/>
  <w:LsdException Locked="false" Priority="66" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium List 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="67" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 1 Accent 6"/>
  <w:LsdException Locked="false" Priority="68" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 2 Accent 6"/>
  <w:LsdException Locked="false" Priority="69" SemiHidden="false"
   UnhideWhenUsed="false" Name="Medium Grid 3 Accent 6"/>
  <w:LsdException Locked="false" Priority="70" SemiHidden="false"
   UnhideWhenUsed="false" Name="Dark List Accent 6"/>
  <w:LsdException Locked="false" Priority="71" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Shading Accent 6"/>
  <w:LsdException Locked="false" Priority="72" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful List Accent 6"/>
  <w:LsdException Locked="false" Priority="73" SemiHidden="false"
   UnhideWhenUsed="false" Name="Colorful Grid Accent 6"/>
  <w:LsdException Locked="false" Priority="19" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtle Emphasis"/>
  <w:LsdException Locked="false" Priority="21" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Emphasis"/>
  <w:LsdException Locked="false" Priority="31" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Subtle Reference"/>
  <w:LsdException Locked="false" Priority="32" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Intense Reference"/>
  <w:LsdException Locked="false" Priority="33" SemiHidden="false"
   UnhideWhenUsed="false" QFormat="true" Name="Book Title"/>
  <w:LsdException Locked="false" Priority="37" Name="Bibliography"/>
  <w:LsdException Locked="false" Priority="39" QFormat="true" Name="TOC Heading"/>
 </w:LatentStyles>
</xml><![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;
	mso-font-charset:2;
	mso-generic-font-family:auto;
	mso-font-pitch:variable;
	mso-font-signature:0 268435456 0 0 -2147483648 0;}
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;
	mso-font-charset:0;
	mso-generic-font-family:roman;
	mso-font-pitch:variable;
	mso-font-signature:-1610611985 1107304683 0 0 159 0;}
@font-face
	{font-family:Cambria;
	panose-1:2 4 5 3 5 4 6 3 2 4;
	mso-font-charset:0;
	mso-generic-font-family:roman;
	mso-font-pitch:variable;
	mso-font-signature:-1610611985 1073741899 0 0 159 0;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;
	mso-font-charset:0;
	mso-generic-font-family:swiss;
	mso-font-pitch:variable;
	mso-font-signature:-1610611985 1073750139 0 0 159 0;}
@font-face
	{font-family:Consolas;
	panose-1:2 11 6 9 2 2 4 3 2 4;
	mso-font-charset:0;
	mso-generic-font-family:modern;
	mso-font-pitch:fixed;
	mso-font-signature:-1610611985 1073750091 0 0 159 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-unhide:no;
	mso-style-qformat:yes;
	mso-style-parent:"";
	margin:0cm;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Calibri","sans-serif";
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:"Times New Roman";
	mso-fareast-theme-font:minor-fareast;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:"Times New Roman";}
h1
	{mso-style-priority:9;
	mso-style-unhide:no;
	mso-style-qformat:yes;
	mso-style-link:"Heading 1 Char";
	mso-margin-top-alt:auto;
	margin-right:0cm;
	mso-margin-bottom-alt:auto;
	margin-left:0cm;
	mso-pagination:widow-orphan;
	mso-outline-level:1;
	font-size:24.0pt;
	font-family:"Cambria","serif";
	mso-ascii-font-family:Cambria;
	mso-ascii-theme-font:major-latin;
	mso-fareast-font-family:"Times New Roman";
	mso-fareast-theme-font:minor-fareast;
	mso-hansi-font-family:Cambria;
	mso-hansi-theme-font:major-latin;
	font-weight:bold;}
h2
	{mso-style-priority:9;
	mso-style-unhide:no;
	mso-style-qformat:yes;
	mso-style-link:"Heading 2 Char";
	mso-margin-top-alt:auto;
	margin-right:0cm;
	mso-margin-bottom-alt:auto;
	margin-left:0cm;
	mso-pagination:widow-orphan;
	mso-outline-level:2;
	font-size:18.0pt;
	font-family:"Calibri","sans-serif";
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:"Times New Roman";
	mso-fareast-theme-font:minor-fareast;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	font-weight:bold;}
h3
	{mso-style-priority:9;
	mso-style-unhide:no;
	mso-style-qformat:yes;
	mso-style-link:"Heading 3 Char";
	mso-margin-top-alt:auto;
	margin-right:0cm;
	mso-margin-bottom-alt:auto;
	margin-left:0cm;
	mso-pagination:widow-orphan;
	mso-outline-level:3;
	font-size:13.5pt;
	font-family:"Calibri","sans-serif";
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:"Times New Roman";
	mso-fareast-theme-font:minor-fareast;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	font-weight:bold;}
p
	{mso-style-noshow:yes;
	mso-style-priority:99;
	mso-margin-top-alt:auto;
	margin-right:0cm;
	mso-margin-bottom-alt:auto;
	margin-left:0cm;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Calibri","sans-serif";
	mso-ascii-font-family:Calibri;
	mso-ascii-theme-font:minor-latin;
	mso-fareast-font-family:"Times New Roman";
	mso-fareast-theme-font:minor-fareast;
	mso-hansi-font-family:Calibri;
	mso-hansi-theme-font:minor-latin;
	mso-bidi-font-family:"Times New Roman";}
pre
	{mso-style-noshow:yes;
	mso-style-priority:99;
	mso-style-link:"HTML Preformatted Char";
	margin:0cm;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	tab-stops:45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;
	font-size:10.0pt;
	font-family:"Courier New";
	mso-fareast-font-family:"Times New Roman";
	mso-fareast-theme-font:minor-fareast;}
span.Heading1Char
	{mso-style-name:"Heading 1 Char";
	mso-style-priority:9;
	mso-style-unhide:no;
	mso-style-locked:yes;
	mso-style-link:"Heading 1";
	mso-ansi-font-size:24.0pt;
	mso-bidi-font-size:24.0pt;
	font-family:"Cambria","serif";
	mso-ascii-font-family:Cambria;
	mso-ascii-theme-font:major-latin;
	mso-fareast-font-family:"Times New Roman";
	mso-fareast-theme-font:minor-fareast;
	mso-hansi-font-family:Cambria;
	mso-hansi-theme-font:major-latin;
	mso-font-kerning:18.0pt;
	font-weight:bold;}
span.Heading2Char
	{mso-style-name:"Heading 2 Char";
	mso-style-noshow:yes;
	mso-style-priority:9;
	mso-style-unhide:no;
	mso-style-locked:yes;
	mso-style-link:"Heading 2";
	mso-ansi-font-size:13.0pt;
	mso-bidi-font-size:13.0pt;
	font-family:"Cambria","serif";
	mso-ascii-font-family:Cambria;
	mso-ascii-theme-font:major-latin;
	mso-fareast-font-family:"Times New Roman";
	mso-fareast-theme-font:major-fareast;
	mso-hansi-font-family:Cambria;
	mso-hansi-theme-font:major-latin;
	mso-bidi-font-family:"Times New Roman";
	mso-bidi-theme-font:major-bidi;
	color:#4F81BD;
	mso-themecolor:accent1;
	font-weight:bold;}
span.Heading3Char
	{mso-style-name:"Heading 3 Char";
	mso-style-noshow:yes;
	mso-style-priority:9;
	mso-style-unhide:no;
	mso-style-locked:yes;
	mso-style-link:"Heading 3";
	mso-ansi-font-size:12.0pt;
	mso-bidi-font-size:12.0pt;
	font-family:"Cambria","serif";
	mso-ascii-font-family:Cambria;
	mso-ascii-theme-font:major-latin;
	mso-fareast-font-family:"Times New Roman";
	mso-fareast-theme-font:major-fareast;
	mso-hansi-font-family:Cambria;
	mso-hansi-theme-font:major-latin;
	mso-bidi-font-family:"Times New Roman";
	mso-bidi-theme-font:major-bidi;
	color:#4F81BD;
	mso-themecolor:accent1;
	font-weight:bold;}
span.HTMLPreformattedChar
	{mso-style-name:"HTML Preformatted Char";
	mso-style-noshow:yes;
	mso-style-priority:99;
	mso-style-unhide:no;
	mso-style-locked:yes;
	mso-style-link:"HTML Preformatted";
	font-family:Consolas;
	mso-ascii-font-family:Consolas;
	mso-fareast-font-family:"Times New Roman";
	mso-fareast-theme-font:minor-fareast;
	mso-hansi-font-family:Consolas;}
.MsoChpDefault
	{mso-style-type:export-only;
	mso-default-props:yes;
	font-size:10.0pt;
	mso-ansi-font-size:10.0pt;
	mso-bidi-font-size:10.0pt;}
@page Section1
	{size:595.3pt 841.9pt;
	margin:72.0pt 72.0pt 72.0pt 72.0pt;
	mso-header-margin:35.4pt;
	mso-footer-margin:35.4pt;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
 /* List Definitions */
 @list l0
	{mso-list-id:113331996;
	mso-list-template-ids:1888233062;}
@list l0:level1
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:36.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	mso-ansi-font-size:10.0pt;
	font-family:Symbol;}
@list l1
	{mso-list-id:995303390;
	mso-list-template-ids:-2004181706;}
@list l1:level1
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:36.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	mso-ansi-font-size:10.0pt;
	font-family:Symbol;}
@list l2
	{mso-list-id:1086270588;
	mso-list-template-ids:-1535874260;}
@list l2:level1
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:36.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	mso-ansi-font-size:10.0pt;
	font-family:Symbol;}
@list l3
	{mso-list-id:1164514467;
	mso-list-template-ids:-1318015516;}
@list l3:level1
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:36.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	mso-ansi-font-size:10.0pt;
	font-family:Symbol;}
@list l4
	{mso-list-id:1367752169;
	mso-list-template-ids:-1879677426;}
@list l4:level1
	{mso-level-number-format:bullet;
	mso-level-text:\F0B7;
	mso-level-tab-stop:36.0pt;
	mso-level-number-position:left;
	text-indent:-18.0pt;
	mso-ansi-font-size:10.0pt;
	font-family:Symbol;}
ol
	{margin-bottom:0cm;}
ul
	{margin-bottom:0cm;}
-->
</style>
<!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-priority:99;
	mso-style-qformat:yes;
	mso-style-parent:"";
	mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
	mso-para-margin:0cm;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman","serif";}
</style>
<![endif]--><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="2050"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1"/>
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-GB link=blue vlink=purple style='tab-interval:36.0pt'>

<div class=Section1>

<h1><span style='mso-fareast-font-family:"Times New Roman"'>Text processing<o:p></o:p></span></h1>

<h2><span style='mso-fareast-font-family:"Times New Roman"'>Strings<o:p></o:p></span></h2>

<p>Strings are <i>vars</i> that contain text.&nbsp; Strings can also store
binary data.</p>

<h3><span style='mso-fareast-font-family:"Times New Roman"'>Creating strings<o:p></o:p></span></h3>

<p>Strings are either &quot;wide&quot; or &quot;narrow&quot;, which refers to
the number of bytes used to represent each character.&nbsp; Narrow strings are
created using double-quotes, and wide strings are prefixed with an L as
follows:</p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>var s1 = &quot;&quot;;<span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// Empty narrow string</pre><pre>var s2 = &quot;Hello&quot;;<span style='mso-spacerun:yes'>&nbsp; </span>// Narrow string</pre><pre>var s3 = L&quot;Hello&quot;; // Wide string</pre><pre>var s4 = +s3;<span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// Clone s3</pre></blockquote>

<h3><span style='mso-fareast-font-family:"Times New Roman"'>Using strings<o:p></o:p></span></h3>

<p>The length of the string is returned by the <i>var::size()</i> method.&nbsp;
A string converts to true (using <i>var::as_bool()</i>) if it is non-empty, or
false if it is empty.&nbsp; Converting to an integer (using <i>var::as_int()</i>)
parses the integer in the string, and if parsing fails, then <i>as_int()</i>
returns 0.</p>

<p>Individual characters can be accessed using the square bracket notation,
starting from index 0.&nbsp; If the requested index is out of range, then the
space character is returned.&nbsp; Negative indexes are counted from the back
of the string.&nbsp; e.g.</p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>var s2 = &quot;Hello&quot;;</pre><pre>writeln( s2[0] );<span style='mso-spacerun:yes'>&nbsp;&nbsp; </span>// Output: H</pre><pre>writeln( s2[-1] );<span style='mso-spacerun:yes'>&nbsp; </span>// Output: o</pre><pre>writeln( s2[100] ); // Output: ' '</pre></blockquote>

<p>The characters of the string can be enumerated using <i>foreach:</i></p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>foreach( ch, &quot;hello&quot; ) write(ch); // Output: hello</pre></blockquote>

<p>The unary + operator clones a string, and the binary + operator concatenates
two strings.&nbsp; The multiplication operator repeats a string a given number
of times.</p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>var s2 = &quot;Hello&quot;;</pre><pre>writeln( s2 + &quot; world!&quot;); // Output: Hello world!</pre><pre>writeln( s2 + 123 );<span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// Output: Hello123</pre><pre>writeln( s2 * 2 );<span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>// Output: HelloHello</pre></blockquote>

<h3><span style='mso-fareast-font-family:"Times New Roman"'>Modifying strings<o:p></o:p></span></h3>

<p>The square brackets operator can be used to set individual characters in the
string.&nbsp; If the index is larger than the current size of the string, then
the string is enlarged, padding with spaces if necessary.</p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>var s = &quot;abc&quot;;</pre><pre>s[3]='d';</pre><pre>writeln(s); // abcd</pre></blockquote>

<p>The += operator appends text to the end of the string, and the *= operator
repeats the string.&nbsp; e.g.</p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>var s = &quot;abc&quot;;</pre><pre>s+=&quot;def&quot;;</pre><pre>writeln(s); // abcdef</pre><pre>s*=2;</pre><pre>writeln(s)<span style='mso-spacerun:yes'>&nbsp; </span>// abcdefabcdef</pre></blockquote>

<p>The <i>var::resize()</i> method changes the size of the string.&nbsp; If the
string is extended, then the space character is used to pad the end of the
string.</p>

<p>The <i>var::clear()</i> method erases the entire string (same as <i>resize(0)</i>).</p>

<p>The <i>var::insert()</i> method inserts one string into another.&nbsp; If
the var inserted isn't a string, it is converted to a string using <i>var::as_string()</i>
first.&nbsp; The first argument is the position, and the second argument is the
string to be inserted.&nbsp; The <i>var::erase()</i> method erases the given
range of characters.&nbsp; e.g.</p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>var s=&quot;hello&quot;;</pre><pre>s.insert(2, &quot;xx&quot;);</pre><pre>writeln(s); // hexxllo</pre><pre>s.erase( range(4,5) );</pre><pre>writeln(s); // hexxo</pre></blockquote>

<p>See&nbsp;<a href="containers.html#Ranges">here</a> for an explanation of the
<i>range()</i> function.</p>

<h3><span style='mso-fareast-font-family:"Times New Roman"'>Comparing strings<o:p></o:p></span></h3>

<p>Strings are compared in lexographic (dictionary) order.&nbsp; It is not
possible to compare narrow strings with wide strings - you'd need to convert
the narrow string to wide using <i>var::as_wstring()</i>.</p>

<h3><span style='mso-fareast-font-family:"Times New Roman"'>Substrings<o:p></o:p></span></h3>

<p>The <i>substring()</i> function returns a section of a string.&nbsp; Its
first argument is the string, and the second argument is a range.&nbsp; e.g.</p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>writeln( substring(&quot;hello&quot;, range(1,2) ) ); // Output: el</pre></blockquote>

<h3><span style='mso-fareast-font-family:"Times New Roman"'>Searching strings<o:p></o:p></span></h3>

<ul type=disc>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l4 level1 lfo1;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var string_find(var haystack, var needle)</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> - returns an array of
     ranges where <i>needle </i>is found in <i>haystack</i><o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l4 level1 lfo1;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var split_chars(var predicate, var string)</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> - returns an array of
     strings, grouped together using the predicate function. &nbsp;The second
     argument can also be the characters of a file (enumerated using <i>characters(file)</i>).<o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l4 level1 lfo1;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var string_find(var haystack, var needle)</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> - returns the range
     where string <i>needle </i>is contained in the string haystack, or <i>null</i>
     of the string is not found.<o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l4 level1 lfo1;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var string_find_last(var haystack, var needle)</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> - returns the range of
     the last occurrence of the string needle in the string haystack, or <i>null</i>
     if the string was not found<o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l4 level1 lfo1;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var string_find_all(var haystack, var needle)</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> - returns an array of
     ranges where the string <i>needle </i>is found in the string <i>haystack</i>.
     The empty array is returned if <i>needle</i> does not appear in <i>haystack</i>.<o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l4 level1 lfo1;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var is_one_of(var str, var ch)</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> - returns true if <i>ch
     </i>is contained in the string <i>str</i>.<o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l4 level1 lfo1;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var is_not_one_of(var str, var ch)</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> - returns true if <i>ch
     </i>is not contained in the string <i>str</i>.<o:p></o:p></span></li>
</ul>

<p>Example (<a href="split.cpp">split.cpp</a>):</p>

<pre style='margin-left:30.0pt'>#include <cppscript>&lt;cppscript&gt;</pre><pre
style='margin-left:30.0pt'><o:p>&nbsp;</o:p></pre><pre style='margin-left:30.0pt'>var script_main(var)<br>
{</pre><pre style='margin-left:30.0pt'><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>var text = &quot;The cat sat on the mat&quot;;</pre><pre
style='margin-left:30.0pt'><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>var is_not_space = bind( is_not_one_of, &quot; \t\r\n&quot; );</pre><pre
style='margin-left:30.0pt'><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>foreach( word, split_chars( is_not_space, text ) )</pre><pre
style='margin-left:30.0pt'><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>writeln(word);</pre><pre
style='margin-left:30.0pt'><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>return 0;</pre><pre
style='margin-left:30.0pt'>}</cppscript></pre>

<h2><span style='mso-fareast-font-family:"Times New Roman"'>Files<o:p></o:p></span></h2>

<p>There are various types of file, corresponding to files on disk, in-memory
files and the console. &nbsp;The functions used to create files are:</p>

<ul type=disc>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l3 level1 lfo2;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var read_file(var filename) -</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> opens a file for
     reading.&nbsp; If the open fails then this function throws <i>&quot;io_error&quot;</i>.<o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l3 level1 lfo2;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var write_file(var filename) -</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> opens a file for
     writing. &nbsp;If the open fails then this function throws <i>&quot;io_error&quot;</i>.<o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l3 level1 lfo2;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var open_file(var filename, std::ios_base::open_mode) -</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> opens a file using the
     specified flags (advanced)<o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l3 level1 lfo2;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var mem_file() -</span></i><span style='mso-fareast-font-family:
     "Times New Roman"'> opens an in-memory file.<o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l3 level1 lfo2;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var in() -</span></i><span style='mso-fareast-font-family:
     "Times New Roman"'> returns the console input<o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l3 level1 lfo2;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var out() -</span></i><span style='mso-fareast-font-family:
     "Times New Roman"'> &nbsp;returns the console output<o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l3 level1 lfo2;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var err() -</span></i><span style='mso-fareast-font-family:
     "Times New Roman"'> return the console error output<o:p></o:p></span></li>
</ul>

<p class=MsoNormal><span style='mso-fareast-font-family:"Times New Roman"'>Files
are objects with the following methods (not all files have all methods, e.g.
the output files don't have input methods etc). <o:p></o:p></span></p>

<ul type=disc>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l2 level1 lfo3;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var &quot;readln&quot;() -</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> reads a line of input,
     and returns a string.&nbsp; Returns null if no more input.<o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l2 level1 lfo3;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var &quot;readch&quot;() -</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> reads a single
     character, or returns null if no more input is available.<o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l2 level1 lfo3;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var &quot;read&quot;() -</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> reads the rest of the
     input, and returns a string.&nbsp; Returns null if no more input.<o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l2 level1 lfo3;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>void &quot;write&quot;() -</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> writes the string to
     the stream<o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l2 level1 lfo3;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>void &quot;writech&quot;() -</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> writes a character to
     the stream<o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l2 level1 lfo3;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>void &quot;writeln&quot;() -</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> writes a line to the
     stream.<o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l2 level1 lfo3;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>void &quot;rewind&quot;() -</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> reads from the start of
     the file again.<o:p></o:p></span></li>
</ul>

<p>For random-access to files, the platform, C and C++ file functions must be
used (though this may come in a later version).</p>

<p>The <i>&quot;io_error&quot;</i> exception (a var with class_name
&quot;io_error&quot;) is thrown if there is an IO error (other than end-of-file
which returns <i>null</i>).</p>

<p>Files can be enumerated using the <i>lines()</i> and <i>characters()</i> function.</p>

<ul type=disc>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l0 level1 lfo4;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var lines(var file) -</span></i><span style='mso-fareast-font-family:
     "Times New Roman"'> enumerates all lines in a file<o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l0 level1 lfo4;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var characters(var file) -</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> enumerates all
     characters in a file<o:p></o:p></span></li>
</ul>

<p>This example implements a simple &quot;grep&quot; program to list
occurrences of a&nbsp;string in a set of files.&nbsp; (<a href="grep.cpp">grep.cpp</a>)</p>

<pre style='margin-left:30.0pt'>#include &lt;cppscript&gt;</pre><pre
style='margin-left:30.0pt'><o:p>&nbsp;</o:p></pre><pre style='margin-left:30.0pt'>void search_for_string_in_file(var str, var filename)</pre><pre
style='margin-left:30.0pt'>{</pre><pre style='margin-left:30.0pt'><span
style='mso-tab-count:1'>&nbsp;&nbsp; </span>try</pre><pre style='margin-left:
30.0pt'><span style='mso-tab-count:1'>&nbsp;&nbsp; </span>{</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>var file = read_file(filename);</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>finally( file[&quot;close&quot;] );</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>var line_no = 1;</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>foreach(line, lines(file))</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>if( string_find( line, str ) )</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:4'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>writeln( filename + &quot;:&quot; + line_no + &quot; &quot; + line );</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:3'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>++line_no;</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:1'>&nbsp;&nbsp; </span>}</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:1'>&nbsp;&nbsp; </span>catch( var )</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:1'>&nbsp;&nbsp; </span>{</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>err()[&quot;writeln&quot;](&quot;Error reading from file &quot; + filename);</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:1'>&nbsp;&nbsp; </span>}</pre><pre
style='margin-left:30.0pt'>}</pre><pre style='margin-left:30.0pt'><o:p>&nbsp;</o:p></pre><pre
style='margin-left:30.0pt'>void search_for_string_in_files(var str, var files)</pre><pre
style='margin-left:30.0pt'>{</pre><pre style='margin-left:30.0pt'><span
style='mso-tab-count:1'>&nbsp;&nbsp; </span>foreach( file, files ) search_for_string_in_file(str, file);</pre><pre
style='margin-left:30.0pt'>}</pre><pre style='margin-left:30.0pt'><o:p>&nbsp;</o:p></pre><pre
style='margin-left:30.0pt'>var script_main(var input)</pre><pre
style='margin-left:30.0pt'>{</pre><pre style='margin-left:30.0pt'><span
style='mso-tab-count:1'>&nbsp;&nbsp; </span>if(input.size()&lt;2) </pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:1'>&nbsp;&nbsp; </span>{</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>err()[&quot;writeln&quot;](&quot;Usage: grep search_term file1 file2 ...&quot;);</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>return 1;</pre><pre><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>}</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:1'>&nbsp;&nbsp; </span>search_for_string_in_files(input[0], tail(input));</pre><pre
style='margin-left:30.0pt'><span style='mso-tab-count:1'>&nbsp;&nbsp; </span>return 0;</pre><pre
style='margin-left:30.0pt'>}</pre>

<h2><span style='mso-fareast-font-family:"Times New Roman"'>Pickling<o:p></o:p></span></h2>

<p>Pickling is the process of converting a var into a string (where it can be
saved in a file, or transmitted across the network).&nbsp; Pickling makes it
easy to save program state without fussing about file formats.</p>

<p>Pickling saves the object structure, for example if you have complex data
structure with loops (also objects with closures have loops), then the object
structure is preserved.</p>

<p>The slight complication comes when you pickle an object which contains
methods.&nbsp; The &quot;methods&quot; cannot be pickled, and the only thing
that can be saved is a reference to the function.&nbsp; However the
&quot;identity&quot; of a function in C++ is its address, which could easily
change between versions and platforms.&nbsp; Therefore storing the function
address in the pickled object is not practical for long term storage.</p>

<p>For this reason, functions to be pickled must be declared (registered) to
C++Script using the macro <i>allow_pickle(function_name)</i>, written outside
of a function definition.&nbsp; Any attempt to pickle a function not declared
in this way throws an exception <i>not_found</i>.&nbsp; Beware of function
overloading (where the same function name is used to denote different functions
with different arguments).</p>

<p>The <i>pickle()</i> function converts any <i>var</i> (with a few exceptions,
such as iterators and native C++ types) into a string, and the <i>unpickle()</i>
function converts a pickled string back into a <i>var</i>.&nbsp; If <i>unpickle()</i>
encounters an error decoding the string, it throws the exception of type <i>&quot;invalid_string</i>&quot;.</p>

<p>e.g. (<a href="history.cpp">history.cpp</a>)</p>

<blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><pre>#include &lt;cppscript&gt;</pre><pre><o:p>&nbsp;</o:p></pre><pre>void clear_history(var history) { history[&quot;list&quot;].clear(); }</pre><pre>enable_pickle(clear_history);</pre><pre><o:p>&nbsp;</o:p></pre><pre>void add_history(var history, var line) { history[&quot;list&quot;].push_back(line); }</pre><pre>enable_pickle(add_history);</pre><pre><o:p>&nbsp;</o:p></pre><pre>void print_history(var history)</pre><pre>{</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>if(history[&quot;list&quot;])</pre><pre><span
style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>foreach( line, history[&quot;list&quot;] ) writeln(line);</pre><pre><span style='mso-spacerun:yes'>&nbsp; </span><span style='mso-spacerun:yes'>&nbsp;&nbsp;</span>else</pre><pre><span
style='mso-tab-count:1'>&nbsp; </span><span style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>writeln(&quot;(history is empty)&quot;);</pre><pre>}</pre><pre>enable_pickle(print_history);</pre><pre><o:p>&nbsp;</o:p></pre><pre>var command_history()</pre><pre>{</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>return object(&quot;command_history&quot;).extend</pre><pre><span
style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;clear&quot;, clear_history)</pre><pre><span
style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;add&quot;, add_history)</pre><pre><span
style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;print&quot;, print_history)</pre><pre><span
style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>(&quot;list&quot;, array());</pre><pre>}</pre><pre><o:p>&nbsp;</o:p></pre><pre>var script_main(var lines)</pre><pre>{</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>var history;</pre><pre><o:p>&nbsp;</o:p></pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>try </pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;</span>{ </pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;</span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp;&nbsp; </span>history=unpickle_file(&quot;history.dat&quot;); </pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;</span>}</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>catch(var) </pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;</span>{ </pre><pre><span
style='mso-tab-count:1'>&nbsp; </span><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;</span><span style='mso-spacerun:yes'>&nbsp;</span><span
style='mso-tab-count:1'>&nbsp;&nbsp;&nbsp; </span>history = command_history(); </pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;</span>} </pre><pre><o:p>&nbsp;</o:p></pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>if(lines[0] == &quot;clear&quot;) </pre><pre><span
style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>history[&quot;clear&quot;]();</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>else </pre><pre><span
style='mso-tab-count:2'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>foreach(line, lines) history[&quot;add&quot;](line);</pre><pre><o:p>&nbsp;</o:p></pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>history[&quot;print&quot;]();</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>pickle_file(&quot;history.dat&quot;, history);</pre><pre><span style='mso-spacerun:yes'>&nbsp;&nbsp;&nbsp; </span>return 0;</pre><pre>}</pre></blockquote>

<ul type=disc>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l1 level1 lfo5;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var pickle(var v)</span></i><span style='mso-fareast-font-family:
     "Times New Roman"'> converts a <i>var</i> to a string<o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l1 level1 lfo5;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var unpickle(var string)</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> converts a string back
     into a <i>var</i><o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l1 level1 lfo5;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>void pickle_file(var filename, var value)</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> stores value into a
     file<o:p></o:p></span></li>
 <li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l1 level1 lfo5;tab-stops:list 36.0pt'><i><span style='mso-fareast-font-family:
     "Times New Roman"'>var unpickle_file(var filename)</span></i><span
     style='mso-fareast-font-family:"Times New Roman"'> retrieves a value from
     a file, or returns <i>null</i> if the file does not exist.<o:p></o:p></span></li>
</ul>

<p><i>pickle()</i> and <i>unpickle()</i> provide a way to deep-copy <i>vars</i>.</p>

</div>

</body>

</html>
